<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Internal functions for gap</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body>

<table width="100%" summary="page for gap-internal"><tr><td>gap-internal</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>Internal functions for gap</h2>

<h3>Description</h3>

<p>These are internal functions.
</p>
<p>PARn calculates population attributable risk (PAR) for a list of frequencies and relative risks (RRs).
</p>
<p>HapDesign and HapFreqSE both accept a <code>haplo.em</code> object to derieve a design/dosage
matrix and standard error of haplotype frequency estimates. The former is appropriate for haplotype trend 
regression (HTR), e.g., within the generalized linear model (GLM) framework to be equivllant to a formal 
approach as implemented in the package haplo.stats and hap.score. However, they are expected to be compatible 
with objects from gc.em() <code>gc.em</code> and <code>hap.em</code>. The two functions are 
included as courtesy of Prof Andrea Foulkes from the useR!2008 tutorial.
</p>
<p>a2g gives allele-to-genotype conversion.
</p>
<p>chr_pos_a1_a2 produces SNPID format.
</p>
<p>circos.cnvplot produces circos plot of CNVs
</p>
<p>circos.cis.vs.trans.plot gives circos plot of cis/trans classification
</p>
<p>circos.mhtplot generates circos Manhattan plot with gene annotation
</p>
<p>cis.vs.trans.classification classifies hits, usually SNPs with associate id and (b)ase-(p)air position, to be cis or trans according to a panel which contains id, chr, start, end, gene variables.
</p>
<p>cnvplot is a cutomised function to plot CNVs genomewide
</p>
<p>cs is for calculation of credible set.
</p>
<p>g2a returns two alleles according to a genotype identifier.
</p>
<p>g2a.c is the C version of g2c.
</p>
<p>gc.control is used by gc.em().
</p>
<p>gc.lambda estimates the genomic control inflation statistic (lambda)
</p>
<p>gcode is as a2g.
</p>
<p>grec2g is undocumented.
</p>
<p>h2G is a utility function for heritability
</p>
<p>h2GE is a utility function for heritability involving gene-environment interaction
</p>
<p>h2l is a utility function for converting observed heritability to its counterpart under liability threshold model
</p>
<p>hap.control is used by hap.em().
</p>
<p>hap.score.glm, hap.score.podds are used by hap.score().
</p>
<p>invlogit, inverse logit transformation.
</p>
<p>inv_chr_pos_a1_a2 is the inverse function of chr_pos_a1_a2.
</p>
<p>invnormal, inverse normal transformation.
</p>
<p>is.miss is undocumented.
</p>
<p>KCC calculates disease prevalences in cases and controls for a given genotype relative risk, 
allele frequency and prevalencen of the disease in the whole population. It is used by tscc
and pbsize2.
</p>
<p>k obtains 1st and 2nd order culumants for correlation coefficient.
</p>
<p>log10p is log10(p) for a normal deviate
</p>
<p>logp is log(p) for a normal deviate
</p>
<p>m2plem is an experimental function for PLEM format.
</p>
<p>mhtplot2d is for 2D Manhattan plot
</p>
<p>miamiplot is for Miami plot.
</p>
<p>micombine is used to combine imputation results.
</p>
<p>plem2m is also experimental for PLEM format.
</p>
<p>ReadGRM is a function to read GCTA grm.gz and grm.id file
</p>
<p>ReadGRMPLINK is a function to read PLINK PI_HAT as a genomic relationship matrix
</p>
<p>ReadGRMPCA is a function to read .eigenval and .eigenvec files from gcta &ndash;pca
</p>
<p>ReadGRMBin is a function to read GCTA grm.bin files, modified from GCTA documentation
</p>
<p>revhap recovers the allele indices for a given haplotype ID in a multiallelic system.
</p>
<p>revhap.i is similar to revhap.
</p>
<p>snptest_sample generates a sample file for SNPTEST.
</p>
<p>solve.skol is a function used by tscc.
</p>
<p>toETDT a function used to experiment with ETDT.
</p>
<p>ungcode recovers alleles from genotype(s).
</p>
<p>VR is a utility function for calculating variance of a ratio
</p>
<p>WriteGRM is a utility function to write GCTA grm.gz and grm.id files
</p>
<p>WriteGRMBin is a utility function to write GCTA grm.bin files
</p>
<p>WriteGRMSAS is a utility function to write a GRM object to SAS PROCs MIXED/GLIMMIX ldata
</p>
<p>x2 is a simple chi-squared test of two proportions.
</p>
<p>z is a normal z-test of two proportions used by tscc.
</p>


<h3>Usage</h3>

<pre>
a2g(a1,a2)
chr_pos_a1_a2(chr,pos,a1,a2,prefix="chr",seps=c(":","_","_"),uppercase=TRUE)
cis.vs.trans.classification(hits,panel,id,radius=1e6)
g2a(g)
g2a.c(g)
h2G(V,VCOV,verbose=TRUE)
h2GE(V,VCOV,verbose=TRUE)
h2l(K=0.05,P=0.5,h2,se,verbose=TRUE)
inv_chr_pos_a1_a2(chr_pos_a1_a2,prefix="chr",seps=c(":","_","_"))
KCC(model,GRR,p1,K)
ReadGRM(prefix=51)
ReadGRMBin(prefix, AllN=FALSE, size=4)
ReadGRMPLINK(prefix, diag=1)
ReadGRMPCA(prefix)
revhap(loci,hapid)
snptest_sample(data,sample_file="snptest.sample",ID_1="ID_1",ID_2="ID_2",
               missing="missing",C=NULL,D=NULL,P=NULL)
VR(v1,vv1,v2,vv2,c12)
WriteGRM(prefix=51,id,N,GRM)
WriteGRMBin(prefix, grm, N, id, size=4)
WriteGRMSAS(grmlist, outfile="gwas")
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>a1</code></td>
<td>
<p>Allele 1</p>
</td></tr>
<tr valign="top"><td><code>a2</code></td>
<td>
<p>Allele 2</p>
</td></tr>
<tr valign="top"><td><code>g</code></td>
<td>
<p>A genotype identifier</p>
</td></tr>
<tr valign="top"><td><code>model</code></td>
<td>
<p>One of &quot;multiplicative&quot;, &quot;additive&quot;, &quot;recessive&quot;, &quot;dominant&quot;, &quot;overdominant&quot;</p>
</td></tr>
<tr valign="top"><td><code>GRR</code></td>
<td>
<p>Genotype relative risk</p>
</td></tr>
<tr valign="top"><td><code>p1</code></td>
<td>
<p>Frequency of the risk allele</p>
</td></tr>
<tr valign="top"><td><code>K</code></td>
<td>
<p>Prevalence of disease in the population</p>
</td></tr>
<tr valign="top"><td><code>loci</code></td>
<td>
<p>A vector of number of alleles at all loci</p>
</td></tr>
<tr valign="top"><td><code>hapid</code></td>
<td>
<p>Haplotype identifier</p>
</td></tr>
</table>


<h3>Details</h3>

<p>These functions are not so frequently called by users</p>


<h3>Examples</h3>

<pre>
## Not run: 
#
cnvplot(cnv)
circos.cnvplot(cnv)
#
cvt &lt;- cis.vs.trans.classification(hits=jma.cojo, panel=inf1, id="uniprot")
cvt
#
circos.cis.vs.trans.plot(hits="INF1.clumped", panel=inf1, id="uniprot")
#
require(gap.datasets)
g &lt;- c("IRS1","SPRY2","FTO","GRIK3","SNED1","HTR1A","MARCH3","WISP3",
       "PPP1R3B","RP1L1","FDFT1","SLC39A14","GFRA1","MC4R")
circos.mhtplot(mhtdata,g)
#
# zcat METAL/4E.BP1-1.tbl.gz | \
# awk 'NR==1 || ($1==4 &amp;&amp; $2 &gt;= 187158034 - 1e6 &amp;&amp; $2 &lt; 187158034 + 1e6)' &gt;  4E.BP1.z
tbl &lt;- within(read.delim("4E.BP1.z"),{logp &lt;- logp(Effect/StdErr)})
z &lt;- cs(tbl)
l &lt;- cs(tbl,log_p="logp")
#
d &lt;- read.table("INF1.merge.cis.vs.trans",as.is=TRUE,header=TRUE)
mhtplot2d(d)
#
d &lt;- data.frame(ID_1=1,ID_2=1,missing=0,PC1=1,PC2=2,D1=1,P1=10)
snptest_sample(d,C=paste0("PC",1:2),D=paste0("D",1:1),P=paste0("P",1:1))
#
s &lt;- chr_pos_a1_a2(1,c(123,321),letters[1:2],letters[2:1])
inv_chr_pos_a1_a2(s)
inv_chr_pos_a1_a2("chr1:123-A_B",seps=c(":","-","_"))

## End(Not run)
</pre>


</body></html>
